package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsSpikeActivity;
import com.mall.mapper.SmsSpikeActivityMapper;
import com.mall.service.SmsSpikeActivityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsSpikeActivityServiceImpl extends ServiceImpl<SmsSpikeActivityMapper, SmsSpikeActivity> implements SmsSpikeActivityService {

    @Resource
    private SmsSpikeActivityMapper smsSpikeActivityMapper;

    @Override
    public SmsSpikeActivity getById(Integer id) {
        return smsSpikeActivityMapper.selectById(id);
    }

    @Override
    public List<SmsSpikeActivity> getAll() {
        List<SmsSpikeActivity> list = smsSpikeActivityMapper.selectList(null);
        return list;
    }

    @Override
    public boolean Save(SmsSpikeActivity smsSpikeActivity) {
        if(smsSpikeActivity.getId() == null)
        {
            return smsSpikeActivityMapper.insert(smsSpikeActivity) > 0;
        }else{
            return  smsSpikeActivityMapper.updateById(smsSpikeActivity) > 0;
        }

    }

    @Override
    public boolean delete(Integer id) {
        return smsSpikeActivityMapper.deleteById(id) > 0;
    }
}
